/*选择时间的插件*/
function  CheckTime(year,month,day){
	this.year = year;
	this.month = month;
	this.day = day;
}
CheckTime.prototype.doyear = function(){
	var select = this.year;
	var thisYear = new Date().getFullYear();
	for(var i = 1900; i <= thisYear; i++) {
		var option = document.createElement("option");
		option.value = i;
		option.innerText = i;
		select.appendChild(option);
	}
}
CheckTime.prototype.domoth = function(){ 
	var select = this.month;
	for(var i = 1; i <= 12; i++) {
		var option = document.createElement("option");
		option.value = i;
		option.innerText = i;
		select.appendChild(option);
	}
}
CheckTime.prototype.doday = function(){ 
	var select = this.day;
	var selectYear = parseInt(this.year.options[this.year.selectedIndex].value);
	var selectMonth = parseInt(this.month.options[this.month.selectedIndex].value);
	var date = new Date(selectYear, selectMonth, 0);

	for(var i = 1; i <= date.getDate(); i++) {
		var option = document.createElement("option");
		option.value = i;
		option.innerText = i;
		select.appendChild(option);
	}
}
CheckTime.prototype.deleteOldChildNodes = function(){ 
	var node = this.day.firstChild;
	var tmpNode;
	while(node != this.day.lastChild) {
		tmpNode = node.nextSibling;
		this.day.removeChild(node);
		node = tmpNode;
	}
	this.day.removeChild(this.day.lastChild);
}

CheckTime.prototype.pageInit = function(){ 
	this.doyear();
	this.domoth();
	this.doday();
	var _this = this;
	this.year.onchange = function() {
		_this.deleteOldChildNodes();
		_this.doday();
	};
	this.month.onchange = function() {
		_this.deleteOldChildNodes();
		_this.doday();
	};
}
